﻿using System.Linq;
using AB.ServiceDirectory.Commons.DataFilters;
using AB.ServiceDirectory.Dao;
using AB.ServiceDirectory.Entities;

namespace AB.ServiceDirectory.BO
{
    public sealed class TrustRegionsBO
    {
        private static readonly TrustRegionsDao Dao = new TrustRegionsDao();

        private TrustRegionsBO()
        {
        }

        /// <summary>
        /// Gets the trust region.
        /// </summary>
        /// <param name="filter">The filter.</param>
        /// <param name="sortType">Type of the sort.</param>
        /// <param name="startRowIndex">Start index of the row.</param>
        /// <param name="maxRows">The max rows.</param>
        /// <returns></returns>
        public static IQueryable<TrustRegion> GetTrustRegion(TrustRegionsFilter filter, string sortType,
                                                             int startRowIndex, int maxRows)
        {
            return Dao.GetList(filter, sortType, startRowIndex, maxRows);
        }

        /// <summary>
        /// Gets the trust region by id.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <returns></returns>
        public static TrustRegion GetTrustRegionById(int id)
        {
            return Dao.GetTrustRegionsId(id);
        }

        /// <summary>
        /// Gets the trust region count.
        /// </summary>
        /// <param name="filter">The filter.</param>
        /// <returns></returns>
        public static int GetTrustRegionCount(TrustRegionsFilter filter)
        {
            return Dao.GetListCount(filter);
        }

        /// <summary>
        /// Inserts the trust region.
        /// </summary>
        /// <param name="trustRegion">The trust region.</param>
        /// <returns></returns>
        public static bool InsertTrustRegion(TrustRegion trustRegion)
        {
            return Dao.AddTrustRegion(trustRegion);
        }

        /// <summary>
        /// Edits the trust region.
        /// </summary>
        /// <param name="trustRegion">The trust region.</param>
        /// <returns></returns>
        public static bool EditTrustRegion(TrustRegion trustRegion)
        {
            return Dao.EditTrustRegions(trustRegion);
        }

        /// <summary>
        /// Adds the trust region.
        /// </summary>
        /// <param name="newTrustRegion">The new trust region.</param>
        /// <returns></returns>
        /// <summary>
        /// Sets the trust region status.
        /// </summary>
        /// <param name="trustRegionId">The trust region id.</param>
        /// <param name="status">if set to <c>true</c> [status].</param>
        /// <returns></returns>
        public static bool SetTrustRegionStatus(int trustRegionId, bool status)
        {
            return Dao.SetTrustRegionStatus(trustRegionId, status);
        }

        /// <summary>
        /// Checks the name of the trust region.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <returns></returns>
        public static bool CheckTrustRegionName(string name)
        {
            return Dao.CheckTrustRegionName(name);
        }
    }
}